Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Is there a way to compare "\x3C!--" with "<!--" and get 'true' in JavaScript?

In one of my projects I have to parse HTML pages and to check if each parsed "tag candidate" is in the predefined list of tag defining strings.

The problem emerges when for some reason the parser returns "\x3C!--" as the "tag candidate", so I get false when comparing it with "<!--" from the list.

Is there any way to get true comparing those strings?

UPDATE:

To clarify my question and to explain where the error occurs I add two screenshots from DevTools panel, Google Chrome, version 104.0.5083.0 (Official Build) dev (64-bit).

Paused in debugger 1

We can see that the value of nodeParse.tagOpening is changed almost immediately after it has been assigned. It's quite strange.

Paused in debugger 2

But it's even more strange that if I open properties of nodeParse object in Local Scope, the correct (initially assigned) value is shown for tagOpening.

So it seems the browser knows that both shown values are actually equivalent, but for some reason distinguishes them. Any comments?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Within a HTML document <!-- is the opening delimiter for comments, even within <script> tags, see HTML-like Comments, so I would avoid including it as a string in your code.

Instead, you could just use the hex escape sequence in the tag-defining string in the first place. For example:

nodeParse.tagOpening = '\x3C!--';
nodeData.tagStarter = '\x3C!--';
about 4 years ago · Juan Pablo Isaza Report

0

After a deeper investigation I have revealed that "\x3C!--" == "<!--" is always true, with no extra efforts (see the screenshot below).

We should keep in mind however that string "<!--" (and any longer one) is stored as is in a variable, but is transformed into "\x3C!--" when is stored in an object's property. At least in Google Chrome.

So we should assign the object's property to a variable (like var s2 = ob.a;), if we want to get value "<!--" back for sure. It was not known to me, so I have made a mistake in my code.

Paused in debugger 3

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!